package com.qf.game.service;

import com.qf.game.dao.PlayerDao;
import com.qf.game.entity.Player;
import com.qf.game.entity.TongjiSex;

import java.util.List;

/**
 * description:
 * author: Ken
 * 公众号：Java架构栈
 */
public class PlayerService {

    private PlayerDao playerDao = new PlayerDao();

    /**
     * 保存玩家
     * @return
     */
    public int insertPlayer(Player player){
        //保存玩家信息
        return playerDao.insertPlayer(player);
    }

    /**
     * 判断用户名是否存在
     * @param username
     * @return
     */
    public boolean existeUsername(String username){
        return playerDao.existeUsername(username);
    }

    /**
     * 根据用户名和面查询用户信息
     * @return
     */
    public Player queryByUsername(String username, String password){
        return playerDao.queryByUsername(username, password);
    }

    /**
     * 根据用户名查询用户信息
     * @param username
     * @return
     */
    public Player queryByUsername(String username){
        return playerDao.queryByUsername(username);
    }

    /**
     * 修改密码
     * @param username
     * @param newPassword
     * @return
     */
    public int updatePassword(String username, String newPassword){
        return playerDao.updatePassword(username, newPassword);
    }

    /**
     * 修改玩家信息
     * @param player
     * @return
     */
    public int updatePlayer(Player player){
        return playerDao.updatePlayer(player);
    }

    /**
     * 修改玩家欢乐豆数量
     * @param count - 操作的欢乐豆数量
     * @param type - 0 增加 1 减少
     * @return
     */
    public int updatePlayerHappyBean(int count, int type, int pid){
        return playerDao.updatePlayerHappyBean(count, type, pid);
    }


    /**
     * 获取性别的统计信息
     * @return
     */
    public List<TongjiSex> getSexDatas(){
        return playerDao.getSexDatas();
    }
}
